package co.jp.roomy;

import co.jp.roomy.vo.Heya;
import co.jp.roomy.vo.MyKagu;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

public class MyKaguCustomActivity extends Activity {

	private Heya heya;
	private MyKagu myKaguCustom;
	
	@Override
	protected void onCreate(Bundle bundle) {
		super.onCreate(bundle);
		setContentView(R.layout.my_kagu_custom);
		
		Intent intent = getIntent();
		heya = (Heya)intent.getSerializableExtra(MyKaguCustomActivity.this.getString(R.string.heyaKey));
		myKaguCustom = (MyKagu)intent.getSerializableExtra(MyKaguCustomActivity.this.getString(R.string.myKaguCustomKey));
		TextView text = (TextView) this.findViewById(R.id.myKaguSizeTextView);
		text.setText(myKaguCustom.getMyKaguSizeX1().toString()
				+ myKaguCustom.getMyKaguSizeX2().toString()
				+ myKaguCustom.getMyKaguSizeX3().toString()
				+ myKaguCustom.getMyKaguSizeX4().toString()
				+ "×" + myKaguCustom.getMyKaguSizeY1().toString()
				+ myKaguCustom.getMyKaguSizeY2().toString()
				+ myKaguCustom.getMyKaguSizeY3().toString()
				+ myKaguCustom.getMyKaguSizeY4().toString()
				+ "×" + myKaguCustom.getMyKaguSizeZ1().toString()
				+ myKaguCustom.getMyKaguSizeZ2().toString()
				+ myKaguCustom.getMyKaguSizeZ3().toString()
				+ myKaguCustom.getMyKaguSizeZ4().toString()
			);
		
		EditText myKaguName = (EditText) findViewById(R.id.myKaguName);
		myKaguName.setText(myKaguCustom.getMyKaguName());
		EditText myKaguMemo = (EditText) findViewById(R.id.myKaguMemo);
		myKaguMemo.setText(myKaguCustom.getMyKaguMemo());
	}
	/*
	 * 所有一覧ボタン押下
	 */
	public void myKaguListButtonOnClick(View view) {
		Intent intent = new Intent(getApplicationContext(), MyKaguListActivity.class);
		intent.putExtra(this.getString(R.string.heyaKey), heya);
		startActivity(intent);
	}

	/**
	 * 完了ボタン押下時
	 * @param View view
	 */
	public void madoriButtonOnClick(View view) {
		
		String myKaguName = ((EditText) findViewById(R.id.myKaguName)).getText().toString();
		myKaguCustom.setMyKaguName(myKaguName);
		String myKaguMemo = ((EditText) findViewById(R.id.myKaguMemo)).getText().toString();
		myKaguCustom.setMyKaguMemo(myKaguMemo);
		
		//TODO DB更新OR登録
		
		
		Intent intent = new Intent(getApplicationContext(), MadoriActivity.class);
		intent.putExtra(getApplicationContext().getString(R.string.heyaKey), heya);
		startActivity(intent);
		
		
		
	}
	
	/**
	 * 家具種別変更ボタン押下時
	 * @param View view
	 */
	public void selectKaguTypeButtonOnClick(View view) {
		String myKaguName = ((EditText) findViewById(R.id.myKaguName)).getText().toString();
		myKaguCustom.setMyKaguName(myKaguName);
		String myKaguMemo = ((EditText) findViewById(R.id.myKaguMemo)).getText().toString();
		myKaguCustom.setMyKaguMemo(myKaguMemo);
		
		Intent intent = new Intent(getApplicationContext(), SelectKaguCategoryActivity.class);
        intent.putExtra(getApplicationContext().getString(R.string.myKaguCustomKey), myKaguCustom);
		intent.putExtra(getApplicationContext().getString(R.string.heyaKey), heya);
		startActivity(intent);
	}
	
	/**
	 * サイズ変更ボタン押下時
	 * @param View view
	 */
	public void setKaguSizeButtonOnClick(View view) {
		String myKaguName = ((EditText) findViewById(R.id.myKaguName)).getText().toString();
		myKaguCustom.setMyKaguName(myKaguName);
		String myKaguMemo = ((EditText) findViewById(R.id.myKaguMemo)).getText().toString();
		myKaguCustom.setMyKaguMemo(myKaguMemo);
		
		Intent intent = new Intent(getApplicationContext(), SetKaguSizeActivity.class);
        intent.putExtra(getApplicationContext().getString(R.string.myKaguCustomKey), myKaguCustom);
		intent.putExtra(getApplicationContext().getString(R.string.heyaKey), heya);
		startActivity(intent);
	}
}
